package org.springblade.modules.auth.controller;

import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.modules.auth.dto.WeComDto;
import org.springblade.modules.auth.service.IWeComService;
import org.springblade.modules.auth.utils.TokenUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhz
 */
@RestController
@AllArgsConstructor
public class WechatController {


    private final IWeComService weComService;

    @PostMapping("/loginWechat")
    public R loginWechat(@RequestBody WeComDto weComDto){
		return R.data(TokenUtil.createAuthInfo(weComService.loginWechat(weComDto)));
    }
	@PostMapping("/getOpenId")
	public R getOpenId(@RequestBody WeComDto weComDto){
		return R.data(weComService.getOpenId(weComDto.getCode()));
	}
}
